package com.achievement.service.impl;

import com.achievement.domain.bo.HonorApplyBookBO;
import com.achievement.domain.bo.HonorBO;
import com.achievement.domain.dto.honor.HonorAuthorDTO;
import com.achievement.domain.dto.honor.HonorDTO;
import com.achievement.domain.entity.HonorApplyBookEntity;
import com.achievement.domain.entity.HonorApplyInfoEntity;
import com.achievement.domain.entity.HonorEntity;
import com.achievement.domain.param.honor.HonorApplyBookParam;
import com.achievement.domain.param.honor.HonorParam;
import com.achievement.domain.vo.honor.HonorAuthorVO;
import com.achievement.domain.vo.honor.HonorExcelVO;
import com.achievement.domain.vo.honor.HonorVO;
import com.achievement.mapper.HonorMapper;
import com.achievement.mappings.HonorMapping;
import com.achievement.service.IAchievementFileService;
import com.achievement.service.IHonorAuthorService;
import com.achievement.service.IHonorService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.api.ApprovalApi;
import com.common.core.domain.AjaxResult;
import com.common.utils.DateUtils;
import com.common.utils.QueryWrapperUtils;
import com.common.utils.SecurityUtils;
import com.common.utils.bean.BizProcessMessages;
import com.flowable.domain.vo.task.BpmTaskApproveReqVO;
import com.flowable.service.IFlowTaskService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.common.utils.DateUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class HonorServiceImpl extends ServiceImpl<HonorMapper, HonorEntity> implements IHonorService {
    @Autowired
    private HonorMapper honorMapper;
    @Autowired
    private IHonorAuthorService honorAuthorService;
    @Autowired
    private HonorMapping mapping;

    @Autowired
    private IAchievementFileService fileService;
    //流程引擎
    @Autowired
    private IFlowTaskService flowTaskService;

    @Autowired
    private ApprovalApi approvalApi;
    private final static String module_name = "获奖成果";
    @Override
    public List<HonorVO> selectByPage(HonorParam param) {
        LambdaQueryWrapper<HonorEntity> queryWrapper = new LambdaQueryWrapper();
        //奖励名称
        queryWrapper.like(StringUtils.isNotEmpty(param.getName()), HonorEntity::getName, param.getName());
        //奖励级别
        if(StringUtils.isNotEmpty(param.getHonorLevelId())){
            queryWrapper.in(StringUtils.isNotEmpty(param.getHonorLevelId()), HonorEntity::getHonorLevelId, Arrays.asList(param.getHonorLevelId().split(",")));
        }
       //获奖等级
        if(StringUtils.isNotEmpty(param.getHonorGradeId())){
            queryWrapper.in(StringUtils.isNotEmpty(param.getHonorGradeId()), HonorEntity::getHonorGradeId, Arrays.asList(param.getHonorGradeId().split(",")));
        }
        //参与作者
        queryWrapper.like(StringUtils.isNotEmpty(param.getAuthorName()), HonorEntity::getAuthornames, param.getAuthorName());
        //获奖日期
        queryWrapper.ge(ObjectUtils.isNotEmpty(param.getHonorDateStart()), HonorEntity::getHonorDate,param.getHonorDateStart());
        queryWrapper.le(ObjectUtils.isNotEmpty(param.getHonorDateEnd()),HonorEntity::getHonorDate,param.getHonorDateEnd());
        //所属单位
        if(StringUtils.isNotEmpty(param.getUnitId())){
            queryWrapper.in(StringUtils.isNotEmpty(param.getUnitId()), HonorEntity::getUnitId, Arrays.asList(param.getUnitId().split(",")));
        }
        //获奖类型
        queryWrapper.eq(param.getHonorNumber()!=null,HonorEntity::getHonorNumber, param.getHonorNumber());
        //获奖批准号
        queryWrapper.like(StringUtils.isNotEmpty(param.getHonorSn()), HonorEntity::getHonorSn, param.getHonorSn());
        //成果名称
        queryWrapper.like(StringUtils.isNotEmpty(param.getProductName()), HonorEntity::getProductName, param.getProductName());
        //发证机关
        queryWrapper.eq(StringUtils.isNotEmpty(param.getHonorUnit()), HonorEntity::getHonorUnit, param.getHonorUnit());
        //奖励类别
        if(StringUtils.isNotEmpty(param.getHonorTypeId())){
            queryWrapper.in(StringUtils.isNotEmpty(param.getHonorTypeId()), HonorEntity::getHonorTypeId, Arrays.asList(param.getHonorTypeId().split(",")));
        }
        //成果形式
        queryWrapper.like(StringUtils.isNotEmpty(param.getProductMode()), HonorEntity::getProductMode, param.getProductMode());
        //完成单位
        queryWrapper.eq(StringUtils.isNotEmpty(param.getCompleteUnit()), HonorEntity::getCompleteUnit, param.getCompleteUnit());
        //学科门类
        queryWrapper.eq(StringUtils.isNotEmpty(param.getSubjectClassId()), HonorEntity::getSubjectClassId, param.getSubjectClassId());
        //学科分类
        queryWrapper.eq(StringUtils.isNotEmpty(param.getSubjectId()), HonorEntity::getSubjectId, param.getSubjectId());
        //项目来源
        queryWrapper.eq(StringUtils.isNotEmpty(param.getProjectSourceId()), HonorEntity::getProjectSourceId, param.getProjectSourceId());
        //审核状态
        if(StringUtils.isNotEmpty(param.getCheckstatus())){
            queryWrapper.in(StringUtils.isNotEmpty(param.getCheckstatus()), HonorEntity::getCheckstatus, Arrays.asList(param.getCheckstatus().split(",")));
        }

        List<HonorEntity> list = this.list(queryWrapper);
        List<HonorVO> voList = list.stream().map(mapping::entity2Vo).collect(Collectors.toList());
        return voList;
    }

    @Override
    public List<HonorVO> listByPage(HonorParam param){
        HonorBO honorBO=mapping.param2Bo(param);
        if(StringUtils.isNotEmpty(param.getCheckstatus())){
            List<String> checkstatusTypes=Arrays.stream(param.getCheckstatus().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCheckstatusList(checkstatusTypes);
        }
        if(StringUtils.isNotEmpty(param.getUnitId())){
            List<String> unitIds=Arrays.stream(param.getUnitId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setUnitIds(unitIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorType())){
            List<String> honorStateIds=Arrays.stream(param.getHonorType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypes(honorStateIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorTypeId())){
            List<String> honorTypeIds=Arrays.stream(param.getHonorTypeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypeIds(honorTypeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorGradeId())){
            List<String> honorGradeIds=Arrays.stream(param.getHonorGradeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorGradeIds(honorGradeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorLevelId())){
            List<String> honorLevelIds=Arrays.stream(param.getHonorLevelId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorLevelIds(honorLevelIds);
        }
        if(StringUtils.isNotEmpty(param.getProjectSourceId())){
            List<String> projectSourceIds=Arrays.stream(param.getProjectSourceId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setProjectSourceIds(projectSourceIds);
        }
        if(StringUtils.isNotEmpty(param.getCooperationType())){
            List<String> cooperationTypes=Arrays.stream(param.getCooperationType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCooperationTypes(cooperationTypes);
        }
        if(StringUtils.isNotEmpty(param.getSubjectId())){
            List<String> subjectIds=Arrays.stream(param.getSubjectId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectIds(subjectIds);
        }
        if(StringUtils.isNotEmpty(param.getSubjectClassId())){
            List<String> subjectClassIds=Arrays.stream(param.getSubjectClassId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectClassIds(subjectClassIds);
        }
        //科研秘书，当前计划下的所属单位是自己管理单位的所有申报成果数据
        LambdaQueryWrapper<HonorEntity> queryWrapper = new LambdaQueryWrapper();
        QueryWrapperUtils.getParams_NokyryWithAlias(queryWrapper, SecurityUtils.getLoginUser().getUser(),"honor");
        List<HonorVO> voList = honorMapper.listByPage(honorBO,queryWrapper);
        return voList;
    }
    @Override
    public List<HashMap<String, Integer>> listStatistics(HonorParam param){
        HonorBO honorBO=mapping.param2Bo(param);
        if(StringUtils.isNotEmpty(param.getCheckstatus())){
            List<String> checkstatusTypes=Arrays.stream(param.getCheckstatus().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCheckstatusList(checkstatusTypes);
        }
        if(StringUtils.isNotEmpty(param.getUnitId())){
            List<String> unitIds=Arrays.stream(param.getUnitId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setUnitIds(unitIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorType())){
            List<String> honorStateIds=Arrays.stream(param.getHonorType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypes(honorStateIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorTypeId())){
            List<String> honorTypeIds=Arrays.stream(param.getHonorTypeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypeIds(honorTypeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorGradeId())){
            List<String> honorGradeIds=Arrays.stream(param.getHonorGradeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorGradeIds(honorGradeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorLevelId())){
            List<String> honorLevelIds=Arrays.stream(param.getHonorLevelId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorLevelIds(honorLevelIds);
        }
        if(StringUtils.isNotEmpty(param.getProjectSourceId())){
            List<String> projectSourceIds=Arrays.stream(param.getProjectSourceId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setProjectSourceIds(projectSourceIds);
        }
        if(StringUtils.isNotEmpty(param.getCooperationType())){
            List<String> cooperationTypes=Arrays.stream(param.getCooperationType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCooperationTypes(cooperationTypes);
        }
        if(StringUtils.isNotEmpty(param.getSubjectId())){
            List<String> subjectIds=Arrays.stream(param.getSubjectId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectIds(subjectIds);
        }
        if(StringUtils.isNotEmpty(param.getSubjectClassId())){
            List<String> subjectClassIds=Arrays.stream(param.getSubjectClassId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectClassIds(subjectClassIds);
        }
        LambdaQueryWrapper<HonorEntity> queryWrapper = new LambdaQueryWrapper();
        QueryWrapperUtils.getParams_NokyryWithAlias(queryWrapper, SecurityUtils.getLoginUser().getUser(),"honor");
        return honorMapper.listStatistics(honorBO,queryWrapper);
    }


    @Override
    public List<HonorEntity> getListByConditions(HonorDTO honorDTO) {
        QueryWrapper<HonorEntity> queryWrapper = new QueryWrapper();
        List<HonorEntity> list = this.list(queryWrapper);
        return list;
    }

    @Override
    public HonorVO getInfoById(String id) {
        HonorEntity entity = this.getById(id);
        HonorVO honorVO=mapping.entity2Vo(entity);
        List<HonorAuthorVO> honorAuthorVOs=honorAuthorService.honorAuthorListByHonorId(id);
        honorVO.setHonorAuthorVOs(honorAuthorVOs);
        String processInstanceId = entity.getProcessInstanceId();
        //获取当前用户所有的代办列表
        Map<String, String> instanceTaskMap = approvalApi.getInstanceTaskMap(module_name);
        if (com.common.utils.StringUtils.isNotEmpty(processInstanceId) && instanceTaskMap.containsKey(processInstanceId)) {
            honorVO.setTaskId(instanceTaskMap.get(processInstanceId));
            honorVO.setIsAuditor(flowTaskService.IsAuditor(SecurityUtils.getLoginUser().getUser().getUserId().toString(),honorVO.getProcessInstanceId()));
        } else {
            honorVO.setIsAuditor(false);
        }
        String fileIds = entity.getFileIds();
        if (com.common.utils.StringUtils.hasText(fileIds)) {
            String[] fileIdArr = fileIds.split(",");
            List<Map<String, String>> fileInfo = fileService.getFileInfoByFileIds(fileIdArr);
            honorVO.setFileList(fileInfo);
        }
        return honorVO;
    }

    @Override
    public AjaxResult addHonorAndHonorAuthor(HonorDTO dto) {
        boolean returnResult=false;
        Integer submitType = dto.getSubmitType();
        HonorEntity entity = mapping.dto2Entity(dto);
        if(!dto.getHonorAuthorDTOs().isEmpty()){
            List<HonorAuthorDTO> authorDTOS=dto.getHonorAuthorDTOs();
            HonorAuthorDTO authorDTO = authorDTOS.get(0);
            entity.setFirstAuthorId(authorDTO.getPersonId());
            entity.setFirstAuthorName(authorDTO.getAuthorName());
            entity.setFirstAuthorAccount(authorDTO.getAuthorAccount());
            entity.setFirstAuthorSexId(authorDTO.getSexId());
            entity.setFirstAuthorEduDegreeId(authorDTO.getEduDegreeId());
            entity.setFirstAuthorTitleId(authorDTO.getTitleId());
            entity.setFirstAuthorEduLevelId(authorDTO.getEduLevelId());
            String authorPIds= authorDTOS.stream().map(a -> a.getPersonId()).collect(Collectors.joining(","));
            String authorNames= authorDTOS.stream().map(a -> a.getAuthorName()).collect(Collectors.joining(","));
            entity.setAuthorpids(authorPIds);
            entity.setAuthornames(authorNames);
        }else{
            entity.setAuthorpids("");
            entity.setAuthornames("");
        }
        switch (submitType) {
            case 2: // 保存并通过
                entity.setProcessInstanceId("0");
                entity.setCheckdate(DateUtils.parseDate(DateUtils.getTime()));
                entity.setChecker(SecurityUtils.getNickName());
                entity.setCheckstatus(String.valueOf(submitType));
                break;
            case 1: // 提交
                returnResult=this.save(entity);
                if (!returnResult) {
                    return AjaxResult.error(BizProcessMessages.SAVE_FAIL);
                }
                if(returnResult&&!dto.getHonorAuthorDTOs().isEmpty()){
                    honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
                }
                String processInstanceId = null;
                try {
                    //发起流程 业务状态由流程引擎更新
                    processInstanceId = approvalApi.businessEntryApproval(entity.getId(), module_name);
                } catch (Exception e) {
                    AjaxResult.error(BizProcessMessages.SAVE_PARTIAL_SUCCESS);
                }
                return com.common.utils.StringUtils.isEmpty(processInstanceId)
                        ? AjaxResult.error(BizProcessMessages.SAVE_PARTIAL_SUCCESS)
                        : AjaxResult.success(BizProcessMessages.SAVE_SUCCESS);
            default: // 处理 -1（暂存）及其他情况
                entity.setCheckstatus(String.valueOf(submitType));
                break;
        }

        returnResult=this.save(entity);
        if(returnResult&&!dto.getHonorAuthorDTOs().isEmpty()){
            honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
        }
        return returnResult
                ? AjaxResult.success(BizProcessMessages.SAVE_SUCCESS)
                : AjaxResult.error(BizProcessMessages.SAVE_FAIL);
    }
    @Override
    public AjaxResult updateHonorAndHonorAuthor(HonorDTO dto){
        boolean returnResult=false;
        Integer submitType = dto.getSubmitType();
        HonorEntity entity = mapping.dto2Entity(dto);
        if(!dto.getHonorAuthorDTOs().isEmpty()){
            List<HonorAuthorDTO> authorDTOS=dto.getHonorAuthorDTOs();
            HonorAuthorDTO authorDTO = authorDTOS.get(0);
            entity.setFirstAuthorId(authorDTO.getPersonId());
            entity.setFirstAuthorName(authorDTO.getAuthorName());
            entity.setFirstAuthorAccount(authorDTO.getAuthorAccount());
            entity.setFirstAuthorSexId(authorDTO.getSexId());
            entity.setFirstAuthorEduDegreeId(authorDTO.getEduDegreeId());
            entity.setFirstAuthorTitleId(authorDTO.getTitleId());
            entity.setFirstAuthorEduLevelId(authorDTO.getEduLevelId());
            String authorPIds= authorDTOS.stream().map(a -> a.getPersonId()).collect(Collectors.joining(","));
            String authorNames= authorDTOS.stream().map(a -> a.getAuthorName()).collect(Collectors.joining(","));
            entity.setAuthorpids(authorPIds);
            entity.setAuthornames(authorNames);
        }else{
            entity.setAuthorpids("");
            entity.setAuthornames("");
        }
        switch (submitType) {
            case 2: // 保存并通过
                // 当前用户是否是审批人
                boolean isAuditor = dto.getIsAuditor();
                // 审批人直接审核（仅适用于提交类型2且为当前审核人的情况）
                if (isAuditor) {
                    returnResult=this.updateById(entity);
                    if(returnResult){
                        honorAuthorService.deleteAuthorListByHonorId(dto.getId());
                        if(!dto.getHonorAuthorDTOs().isEmpty()){
                            honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
                        }
                        BpmTaskApproveReqVO bta = new BpmTaskApproveReqVO();
                        bta.setId(dto.getTaskId());
                        bta.setReason(SecurityUtils.getNickName() + "保存并通过");
                        try {
                            flowTaskService.approveTask(SecurityUtils.getUserId(), bta);
                        } catch (Exception e) {
                            return AjaxResult.error(BizProcessMessages.SAVE_SUCCESS_APPROVE_FAIL, e.getMessage());
                        }
                        return AjaxResult.success(BizProcessMessages.SAVE_SUCCESS);
                    }
                    return AjaxResult.error(BizProcessMessages.SAVE_FAIL);
                }
                //处理非当前审批人保存并通过
                if (!dto.getCheckstatus().equals("2")){
                    entity.setProcessInstanceId("0");
                }
                entity.setCheckdate(DateUtils.parseDate(DateUtils.getTime()));
                entity.setChecker(SecurityUtils.getNickName());
                //只有管理员才会有非当前审核人的情况下有 "保存并提交"按钮,审核完后的结果只能是审核通过
                entity.setCheckstatus(String.valueOf(submitType));
                break;
            case 1:
                returnResult=this.updateById(entity);
                //暂存转提交
                if (!returnResult) {
                    return AjaxResult.error(BizProcessMessages.SAVE_FAIL);
                }
                honorAuthorService.deleteAuthorListByHonorId(dto.getId());
                if(!dto.getHonorAuthorDTOs().isEmpty()){
                    honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
                }
                String returnProcessInstanceId = null;
                try {
                    returnProcessInstanceId = approvalApi.businessEntryApproval(entity.getId(), module_name);
                } catch (Exception e) {
                    return AjaxResult.error(BizProcessMessages.SAVE_PARTIAL_SUCCESS, e.getMessage());
                }

                return com.common.utils.StringUtils.isEmpty(returnProcessInstanceId)
                        ? AjaxResult.warn(BizProcessMessages.SAVE_PARTIAL_SUCCESS)
                        : AjaxResult.success(BizProcessMessages.SAVE_SUCCESS);
            case -1: // 暂存
                returnResult=this.updateById(entity);
                if (returnResult) {
                    honorAuthorService.deleteAuthorListByHonorId(dto.getId());
                    if(!dto.getHonorAuthorDTOs().isEmpty()){
                        honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
                    }
                }
                return returnResult
                        ? AjaxResult.success(BizProcessMessages.SAVE_SUCCESS)
                        : AjaxResult.error(BizProcessMessages.SAVE_FAIL);
            default:
                break;
        }
        returnResult=this.updateById(entity);
        if(returnResult){
            honorAuthorService.deleteAuthorListByHonorId(dto.getId());
            if(!dto.getHonorAuthorDTOs().isEmpty()){
                honorAuthorService.bitchAdd(dto.getHonorAuthorDTOs(),entity.getId());
            }
        }
        return returnResult
                ? AjaxResult.success(BizProcessMessages.SAVE_SUCCESS)
                : AjaxResult.error(BizProcessMessages.SAVE_FAIL);
    }
    @Override
    public boolean add(HonorDTO dto) {
        HonorEntity entity = mapping.dto2Entity(dto);
        return this.save(entity);
    }

    @Override
    public boolean update(HonorDTO dto) {
        HonorEntity entity = mapping.dto2Entity(dto);
        return this.updateById(entity);
    }

    @Override
    public boolean batchRemove(List<String> ids) {
        boolean returnResult=false;
        returnResult=this.removeByIds(ids);
        if(returnResult){
            for (String id:ids
            ) {
                //遍历删除作者信息
                honorAuthorService.deleteAuthorListByHonorId(id);
            }

        }
        return returnResult;
    }
    @Override
    public List<HonorExcelVO> honorLisExcel(HonorParam param){
        HonorBO honorBO=mapping.param2Bo(param);
        if(StringUtils.isNotEmpty(param.getCheckstatus())&&!param.getCheckstatus().equals("[]")){
            List<String> checkstatusTypes=Arrays.stream(param.getCheckstatus().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCheckstatusList(checkstatusTypes);
        }
        if(StringUtils.isNotEmpty(param.getUnitId())&&!param.getUnitId().equals("[]")){
            List<String> unitIds=Arrays.stream(param.getUnitId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setUnitIds(unitIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorType())&&!param.getHonorType().equals("[]")){
            List<String> honorStateIds=Arrays.stream(param.getHonorType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypes(honorStateIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorTypeId())&&!param.getHonorTypeId().equals("[]")){
            List<String> honorTypeIds=Arrays.stream(param.getHonorTypeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorTypeIds(honorTypeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorGradeId())&&!param.getHonorGradeId().equals("[]")){
            List<String> honorGradeIds=Arrays.stream(param.getHonorGradeId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorGradeIds(honorGradeIds);
        }
        if(StringUtils.isNotEmpty(param.getHonorLevelId())&&!param.getHonorLevelId().equals("[]")){
            List<String> honorLevelIds=Arrays.stream(param.getHonorLevelId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setHonorLevelIds(honorLevelIds);
        }
        if(StringUtils.isNotEmpty(param.getProjectSourceId())&&!param.getProjectSourceId().equals("[]")){
            List<String> projectSourceIds=Arrays.stream(param.getProjectSourceId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setProjectSourceIds(projectSourceIds);
        }
        if(StringUtils.isNotEmpty(param.getCooperationType())&&!param.getCooperationType().equals("[]")){
            List<String> cooperationTypes=Arrays.stream(param.getCooperationType().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setCooperationTypes(cooperationTypes);
        }
        if(StringUtils.isNotEmpty(param.getSubjectId())&&!param.getSubjectId().equals("[]")){
            List<String> subjectIds=Arrays.stream(param.getSubjectId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectIds(subjectIds);
        }
        if(StringUtils.isNotEmpty(param.getSubjectClassId())&&!param.getSubjectClassId().equals("[]")){
            List<String> subjectClassIds=Arrays.stream(param.getSubjectClassId().split(",")).filter(id -> !id.trim().isEmpty()).collect(Collectors.toList());
            honorBO.setSubjectClassIds(subjectClassIds);
        }
        LambdaQueryWrapper<HonorEntity> queryWrapper = new LambdaQueryWrapper();
        QueryWrapperUtils.getParams_NokyryWithAlias(queryWrapper, SecurityUtils.getLoginUser().getUser(),"honor");
        List<HonorExcelVO> voList = honorMapper.honorLisExcel(honorBO,queryWrapper);
        return voList;
    }
}
